package h.a.a.k;

import h.a.a.a;
import h.a.a.j.d;
import h.a.a.k.d.b;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/* compiled from: QueryBuilder */
public class g<T> {
    public final h<T> a;
    public final List<Object> b = new ArrayList();
    public final List<e<T, ?>> c = new ArrayList();
    public final a<T, ?> d;

    public g(a<T, ?> aVar) {
        this.d = aVar;
        this.a = new h(aVar, "T");
    }

    public final void a(StringBuilder stringBuilder, String str) {
        this.b.clear();
        Iterator it = this.c.iterator();
        if (it.hasNext()) {
            e eVar = (e) it.next();
            stringBuilder.append(" JOIN ");
            stringBuilder.append('\"');
            Objects.requireNonNull(eVar);
            throw null;
        }
        if ((this.a.b.isEmpty() ^ 1) != 0) {
            stringBuilder.append(" WHERE ");
            this.a.a(stringBuilder, str, this.b);
        }
        Iterator it2 = this.c.iterator();
        if (it2.hasNext()) {
            Objects.requireNonNull((e) it2.next());
            throw null;
        }
    }

    public f<T> b() {
        String str = "T";
        StringBuilder stringBuilder = new StringBuilder(d.e(this.d.getTablename(), str, this.d.getAllColumns(), false));
        a(stringBuilder, str);
        return f.c(this.d, stringBuilder.toString(), this.b.toArray(), -1, -1);
    }

    public d<T> c() {
        if (this.c.isEmpty()) {
            String tablename = this.d.getTablename();
            StringBuilder stringBuilder = new StringBuilder(d.c(tablename, null));
            a(stringBuilder, "T");
            String stringBuilder2 = stringBuilder.toString();
            stringBuilder = new StringBuilder();
            stringBuilder.append('\"');
            stringBuilder.append(tablename);
            stringBuilder.append("\".\"");
            return (d) new b(this.d, stringBuilder2.replace("T.\"", stringBuilder.toString()), a.b(this.b.toArray()), null).b();
        }
        throw new h.a.a.d("JOINs are not supported for DELETE queries");
    }

    public g<T> d(i iVar, i... iVarArr) {
        h hVar = this.a;
        hVar.b(iVar);
        hVar.b.add(iVar);
        for (i iVar2 : iVarArr) {
            hVar.b(iVar2);
            hVar.b.add(iVar2);
        }
        return this;
    }
}
